import React from 'react';
import { ts2Formatter,renderState,toThousands } from 'utils';
import moment from 'moment';
import { actions } from 'mirrorx';
{/*
可配置化种类：

1、表格头部字段 
    1、列表页表格头部字段集合 mainTableColumn
    2、编辑页表格头部字段集合 childTableColumn

2、编辑框的字段
    1、编辑页 直接显示在页面的编辑字段 FormField
    2、编辑页 需要点击表格的增行弹框编辑的字段 FormTableField
    3. 列表页查询区域  searchField

3.表头部的按钮  headerButtonSets

4.表行尾部按钮  columnButtonSets
*/}

//表头信息

//字段属性

//基本信息
const FormDataHeader = [
        {
            enname: "retailBillCode",
            zhname: "零售单号",
            type:"FormControl",
            edit:false,
            hidepage:{0:true}
        },
        {
            enname: "saleOrgId",
            showname: "saleOrgName",
            codename: "saleOrgCode",
            zhname: "隶属组织",
            multiple:false,
            type: "RefComponent",
            refname:"organization",
            // edit: true,
            edit:true,
            param:{
                "AUTH_refdim":"saleOrg","AUTH_refcod":"retail_order"
            },
            cascadeName: [{
                paramkey: "EQ_organization.id",
                childtype: "DataHeader",
                refKey: "refpk",
                dtoKey: "saleOrgId",
                offers: "ownerShopId",
                resetOffersFlag: true,
            },{
                paramkey: "EQ_organization.id",
                childtype: "DataHeader",
                refKey: "refpk",
                dtoKey: "organizationId",
                offers: "salesDeptId",  
                resetOffersFlag: true,
            },{
                paramkey: "EQ_customerAreas.organization.id",
                childtype: "DataHeader",
                refKey: "refpk",
                dtoKey: "saleOrgId",
                offers: "ownerCustomerId",
                resetOffersFlag: true,
            },{
                paramkey: "EQ_customerAreas.organization.id",
                childtype: "DataHeader",
                refKey: "refpk",
                dtoKey: "saleOrgId",
                offers: "ext20Id",
                resetOffersFlag: true,
            }],
            required: true,
        },
        {
            enname:"ownerShopId",
            codename:"ownerShopCode",
            showname:"ownerShopName",
            zhname:"门店",
            required: true,
            multiple:false,
            type: "RefComponent",
            refname:"terminal",
            edit:true,
            alias:"saleOrgId",
            cascadeName: [{
                paramkey: "EQ_ownerShop.id",
                childtype: "DataHeader",
                refKey: "refpk",
                dtoKey: "ownerShopId",
                offers: "ownerCustomerId",
                resetOffersFlag: true,
            }],
            relation: [
                {
                    ref: "salesDeptId",
                    refpk: "retailId",
                    refname: "retailName",
                    refcode: "retailCode",
                    relationType:"ref"
                },
                {
                    ref: "sliceAreaId",
                    refpk: "regionId",
                    refname: "regionName",
                    refcode: "regionCode",
                    relationType:"ref"
                },
                {
                    ref: "terminalTypeId",
                    refpk: "facadeCategoryId",
                    refname: "facadeCategoryName",
                    refcode: "facadeCategoryCode",
                    relationType:"ref"
                },
            ],
        },
        {
            enname:"retailTypeId",
            codename:"retailTypeCode",
            showname:"retailTypeName",
            showcontrol: [{
                value: "003,004",
                refKey: "code",
                dtoKey: "retailTypeCode",
                layer: ["childTableColumn", "retailOrderItems", "column"],
                fields: ["ext11"]
            }],
            zhname:"零售类型",
            required: true,
            code:"ls001",
            type: "Select",
            edit: true
        },
        {
            enname: "ownerCustomerId",
            codename: "ownerCustomerCode",
            showname: "ownerCustomerName",
            zhname: "客户",
            type: "RefComponent",
            // multiple:true,
            edit:false,
            alias: "ownerShopId,saleOrgId",
            refname:"retailOrderCustomerRef",
            required: true,
            relation: [
                {
                    ref: "shippingareaId",
                    refpk: "shippingareaId",
                    refname: "shippingareaName",
                    refcode: "shippingareaCode",
                    relationType:"ref"
                },
                {
                    ref: "channelId",
                    refpk: "custChanTypeId",
                    refname: "custChanTypeName",
                    refcode: "custChanTypeCode",
                    relationType:"ref"
                },
            ],
        },
        {
            enname: "salesDeptId",
            codename: "salesDeptCode",
            showname: "salesDeptName",
            alias:"saleOrgId",
            zhname: "零售片区",
            refname: "departmentRef",
            param: {
                EQ_enableState: "0",
            },
            type: "RefComponent",
            edit: true,
            required: true,
        },
        {
            enname:"ext11Name",
            zhname:"零售地区",
            required: false,
            hidepage:{0:true,1:true,2:false},
            type: "FormControl",
            edit: false
        },
        {
            enname:"ext12Name",
            zhname:"零售大区",
            required: false,
            hidepage:{0:true,1:true,2:false},
            type: "FormControl",
            edit: false
        },
        {
            enname: "shippingareaId",
            codename: "shippingareaCode",
            showname: "shippingareaName",
            // alias:"saleOrgId",
            zhname: "发运片区",
            refname: "departmentRef",
            param: {
                EQ_enableState: "0",
            },
            type: "RefComponent",
            edit: false,
            required: false,
        },
        {
            enname:"ext13Name",
            zhname:"发运地区",
            required: false,
            hidepage:{0:true,1:true,2:false},
            type: "FormControl",
            edit: false
        },
        {
            enname:"ext14Name",
            zhname:"发运大区",
            required: false,
            hidepage:{0:true,1:true,2:false},
            type: "FormControl",
            edit: false
        },
        {
            enname: "channelId",
            codename: "channelCode",
            showname: "channelName",
            zhname: "客户渠道",
            type: "RefComponent",
            refname:"custchantype",
            required: true,
        },
        // {
        //     enname: "ownerCustomerId",
        //     codename: "ownerCustomerCode",
        //     showname: "ownerCustomerName",
        //     zhname: "业务员",
        //     type: "RefComponent",
        //     multiple:true,
        //     edit:false,
        //     refname:"terminalcustomerRef",
        //     required: false,
        // },
        {
            enname: "sliceAreaId",
            codename: "sliceAreaCode",
            showname: "sliceAreaName",
            zhname: "区域市场",
            type: "RefComponent",
            refname:"marketareas",
            required: true,
        },
        {
            enname: "saleTypeId",
            showname: "saleTypeName",
            codename: "saleTypeCode",
            zhname: "销售类型",
            type: "Select",
            edit: true,
            code:"QY132",
            required: true,
        },
        {
            enname: "purMachineTime",
            zhname: "购机日期",
            format:"YYYY-MM-DD",
            required:true,
            disabledBefore:true,
            defaultValue:moment(),
            disabledDate:"creationTime",
            type: "DatePicker",
            edit: true,
        },
        {
            enname: "serviceModeSrcId",
            codename: "serviceModeSrcCode",
            showname: "serviceModeSrcName",
            zhname: "提货方式",
            type: "Select",
            code: "ls002",
            requirecontrol:[
                {
                    value: "04",
                    refKey: "refcode",
                    dtoKey: "planTypeCode",
                    layer: ["FormField", "DataHeader", "Field"],
                    fields: ["sendTime"]
                }
            ],
            edit: true,
            required: true,
        },
        {
            enname: "terminalTypeId",
            codename: "terminalTypeCode",
            showname: "terminalTypeName",
            zhname: "门店类别",
            type: "RefComponent",
            refname: "facadeCategoryRef",
        },
        {
            enname: "ext20Id",
            codename: "ext20Code",
            showname: "ext20Name",
            zhname: "归属客户",
            type: "RefComponent",
            edit:true,
            alias: "saleOrgId",
            refname:"retailOrderCustomerRef",
        },
        {
            enname: "shopperName",
            zhname: "顾客姓名",
            type: "FormControl",
            pattern:/^\S*$/,
            message: "不能有空格",
            edit: true,
            required: true,
        },
        {
            enname: "shopperPhone",
            zhname: "顾客电话",
            type: "FormControl",
            pattern: /^[0-9]{11}$/,
            message: "11位的数字",
            edit: true,
            required: true,
        },
        {
            enname: "ext01",
            zhname: "顾客电话1",
            type: "FormControl",
            pattern: /^[0-9]{11}$/,
            message: "11位的数字",
            edit: true,
            required: false,
        },
        {
            enname: "installationCode",
            zhname: "安装码",
            type: "FormControl",
            pattern:/^\S*$/,
            message: "不能有空格",
            edit: true,
            required: false,
        },
        {
            enname: "isIncludedCommission",
            zhname: "是否基本提成计入",
            type: "Radio",
            defaultValue: 1,
            options: [{
                "key": 0,
                "value": "否"
            }, {
                "key": 1,
                "value": "是"
            }],
            edit: true,
            required: true,
        },
        {
            enname: "isChangeCommission",
            zhname: "是否变动提成计入",
            type: "Radio",
            defaultValue: 1,
            options: [{
                "key": 0,
                "value": "否"
            }, {
                "key": 1,
                "value": "是"
            }],
            edit: true,
            required: true,
        },
        {
            enname: "isWithSingleCommission",
            zhname: "带单提成计入",
            type: "Radio",
            defaultValue: 1,
            options: [{
                "key": 0,
                "value": "否"
            }, {
                "key": 1,
                "value": "是"
            }],
            edit: true,
            required: true,
        },
        {
            enname: "accountingMethodId",
            codename: "accountingMethodCode",
            showname: "accountingMethodName",
            zhname: "核算方式",
            type: "Select",
            code: "HSFS",
            edit: true,
            required: true,
        },
        {
            enname: "provinceId",
            codename: "provinceCode",
            showname: "provinceName",
            zhname: "省",
            type: "RefComponent",
            refname: "areaRef",
            param: {
                EQ_areaLevel: "1",
            },
            cascadeName: {
                paramkey: "EQ_parent.id",
                childtype: "DataHeader",
                refKey: "refpk",
                dtoKey: "provinceId",
                offers: "cityId",
                resetOffersFlag: true,
            },
            edit: true,
            required: true,
        },
        {
            enname: "cityId",
            codename: "cityCode",
            showname: "cityName",
            zhname: "市",
            refname: "areaRef",
            type: "RefComponent",
            edit: true,
            cascadeName: {
                paramkey: "EQ_parent.id",
                childtype: "DataHeader",
                refKey: "refpk",
                dtoKey: "cityId",
                offers: "countyId",
                resetOffersFlag: true,
            },
            param: {
                EQ_areaLevel: "2",
            },
            alias: "provinceId",
            edit: true,
            required: true,
        },
        {
            enname: "countyId",
            codename: "countyCode",
            showname: "countyName",
            zhname: "区/县",
            refname: "areaRef",
            type: "RefComponent",
            edit: true,
            param: {
                EQ_areaLevel: "3",
            },
            cascadeName: [{
                paramkey: "EQ_parent.id",
                childtype: "DataHeader",
                refKey: "refpk",
                dtoKey: "countyId",
                offers: "townId",
                resetOffersFlag: true,
            },
            {
                paramkey: "EQ_countyCode",
                childtype: "DataHeader",
                refKey: "refcode",
                dtoKey: "countyCode",
                offers: "ext15Id",
                resetOffersFlag: true,
            }],
            alias: "cityId",
            edit: true,
            required: true,
        },
        {
            enname: "townId",
            codename: "townCode",
            showname: "townName",
            zhname: "镇/街道",
            refname: "areaRef",
            type: "RefComponent",
            edit: true,
            param: {
                EQ_areaLevel: "4",
            },
            alias: "countyId",
            edit: true,
            required: true,
        },
        {
            enname: "address",
            zhname: "详细地址",
            type: "FormControl",
            pattern:/^\S*$/,
            message: "不能有空格",
            edit: true,
            required: true,
        },
        {
            enname: "remark",
            zhname: "备注",
            pattern:/^\S*$/,
            message: "不能有空格",
            type: "FormControl",
            edit: true,
        },
        {
            enname:"ext05",
            zhname:"是否上传发票",
            type: "Radio",
            defaultValue: "N",
            options: [{
                "key": "N",
                "value": "否"
            }, {
                "key": "Y",
                "value": "是"
            }],
            edit: true,
            required: false,
        },
        {
            enname:"ext09Id",
            codename:"ext09Code",
            showname:"ext09Name",
            zhname:"套购类型",
            required: true,
            code:"SUIT_STATUS",
            type: "Select",
            edit: true
        },
        {
            enname:"ext16",
            codename:"ext16",
            showname:"ext16",
            required: true,
            zhname:"是否赠送支架",
            type: "Select",
            options: [
                {
                    name: '是', code: "1"
                },
                {
                    name: '否', code: "0"
                },
            ],
            edit: true,
        },
        {
            enname:"ext17",
            codename:"ext17",
            showname:"ext17",
            zhname:"是否售后上门安装",
            type: "Select",
            required: true,
            options: [                
                {
                    name: '是', code: "1"
                },
                {
                    name: '否', code: "0"
                }],
            requirecontrol:[{
                value:"1",
                refkey:"refCode",
                dtoKey:"",
                layer: ["FormField", "DataHeader", "Field"],
                fields: ["sendTime"]
            }],
            edit: true,
        },
        {
            enname: "sendTime",
            zhname: "送装日期",
            type: "DatePicker",
            edit: true,
            required: true,
            disabledDate:"purMachineTime",
            format:"YYYY-MM-DD",
        },
        {
            enname:"ext07",
            zhname:"创建人",
            required: false,
            hidepage:{0:true,1:false,2:false},
            type: "FormControl",
            edit: false
        },
        {
            enname:"creationTime",
            zhname:"创建时间",
            required: false,
            // hidepage:{0:true,1:false,2:false},
            type: "DatePicker",
            defaultValue:moment(),
            format:"YYYY-MM-DD",
            edit: false
        },
        {
            enname:"ext08",
            zhname:"编辑人",
            required: false,
            hidepage:{0:true,1:false,2:false},
            type: "FormControl",
            edit: false
        },
        {
            enname:"modifiedTime",
            zhname:"编辑时间",
            required: false,
            hidepage:{0:true,1:false,2:false},
            type: "DatePicker",
            format:"YYYY-MM-DD",
        },
        {
            // enname: "state",
            codename: "state",
            // showname: "state",
            zhname: "审批状态",
            type: "Select",
            hidepage: { 0: true },
            code: "BILL_STATUS",
            required: false,
            edit: false,
        },
        {
            enname:"approver",
            zhname:"审核人",
            required: false,
            hidepage:{0:true,1:false,2:false},
            type: "FormControl",
            edit: false
        },
        {
            enname:"approveTime",
            zhname:"审核日期",
            required: false,
            hidepage:{0:true,1:false,2:false},
            type: "DatePicker",
            format:"YYYY-MM-DD",
            edit: false
        },
        {
            enname:"totalQuantity",
            zhname:"总数合计",
            required: false,
            type: "InputNumber",
            precision:2,
        },
        {
            enname:"totalAmount",
            zhname:"金额合计",
            required: false,
            type: "InputNumber",
            precision:2,
        },
        {
            enname:"companyUnitCosts",
            zhname:"公司费用合计",
            required: false,
            type: "InputNumber",
            precision:2,
            edit: false
        },
        {
            enname:"marketUnitCosts",
            zhname:"商场费用合计",
            required: false,
            type: "InputNumber",
            precision:2,
            edit: false
        },
        {
            enname:"basicCommissions",
            zhname:"基本提成合计",
            required: false,
            type: "FormControl",
            hidepage:{0:true},
            precision:2,
            edit: false
        },
        {
            enname:"changeCommissions",
            zhname:"变动提成合计",
            required: false,
            type: "FormControl",
            hidepage:{0:true},
            precision:2,
            edit: false
        },
        {
            enname:"singleAmounts",
            zhname:"带单提成合计",
            required: false,
            type: "FormControl",
            hidepage:{0:true},
            precision:2,
            edit: false
        },
        {
            enname:"srcBillOrder",
            // zhname:"相关单号",
            zhname:"数据来源",
            required: false,
            hidepage:{0:true,1:false,2:false},
            type: "FormControl",
            precision:2,
            edit: false
        },
        {
            enname:"srcBillCode",
            // zhname:"相关单号",
            zhname:"来源单号",
            required: false,
            hidepage:{0:true,1:false,2:false},
            type: "FormControl",
            precision:2,
            edit: false
        },
        {
            enname:"ext03",
            zhname:"销售单号",
            required: false,
            hidepage:{0:true,1:true,2:false},
            type: "FormControl",
            edit: false
        }
];
const columnretailOrderItems = [
    // {
    //     title: "商品类别",
    //     dataIndex: "goodsCategoryName",
    //     key: "goodsCategoryId",
    //     renderType: "select",
    //     width:100,
    //     filedProps: {
    //         reffields: { refpk: "goodsCategoryId", refname: "goodsCategoryName", refcode: "goodsCategoryCode" },
    //         options: [
    //             {
    //                 name: '赠品', code: "001", id: "0k7IiLNoo3GbjLUJuIvK"
    //             },
    //             {
    //                 name: '正常机', code: "002", id: "0lDCyg3Q2ThZUbVyyBd7"
    //             },
    //         ]
    //     },
    // },
    {
        title: "商品",
        dataIndex: "goodsName",
        key: "goodsId",
        renderType: "refcomponent",
        width: 200,
        validate: false,
        required:true,
        filedProps: {
            title: "商品",
            refName: "goodsRef",
            fieldName: "goodsName",
            multiple:true,
            offersparam: {
                currentkey: ["brandId", "brandCode", "brandName","model","ext07Id","ext07Code","ext07Name","goodsSeriesId","goodsSeriesCode","goodsSeriesName","goodsSeriesSonId","goodsSeriesSonCode","goodsSeriesSonName"],
                offerfields: ["brandId", "brandCode", "brandName","model","productLineId","productLineCode","productLineName","ext02Id","ext02Code","ext02Name","ext03Id","ext03Code","ext03Name"],
            },
            reffields: { refpk: "goodsId", refname: "goodsName", refcode: "goodsCode" }
        },
    },
    {
        title: "赠品/主商品",
        dataIndex: "isGift",
        key: "isGift",
        renderType: 'selectradio',
        required:true,
        validate:false,
        render: (text, record, index) => {
            if (text == 1) {
                return '赠品';
            } else if(text!=""&&text == 0){
                return '主商品';
            }
        },
        filedProps: {
            reffields: { refpk: "isGift" },
            defaultValue: 0,
            options: [
                {
                    name: '赠品', code: 1
                },
                {
                    name: '主商品', code: 0
                },
            ]
        }
    },
    // {
    //     title: "品牌",
    //     dataIndex: "brandName",
    //     key: "brandName",
    //     width: 100,
    // },
    // {
    //     title: "型号",
    //     dataIndex: "model",
    //     key: "model",
    //     width: 120,
    // },
    // {
    //     title: "品类",
    //     dataIndex: "productLineName",
    //     key: "productLineName",
    //     width: 120,
    // },
    {
        title: "条码产权",
        dataIndex: "ext11",
        key: "ext11",
        renderType: 'selectradio',
        required:true,
        filedProps: {
            reffields: { refpk: "ext11" },
            // defaultValue:"1",
            options: [
                {
                    name: '公司产权', code: "1"
                },
                {
                    name: '商家产权', code: "2"
                },
            ]
        }
    },
    {
        title: "机身条码",
        dataIndex: "machineBarCode",
        key: "machineBarCode",
        renderType: "input",
        width: 200,
        pattern:/^\S*$/,
        patternMessage: "不能有空格",
        filedProps: {
            maxLenght: "25",
        },
        validate: false,
    },
    {
        title: "数量",
        dataIndex: "amount",
        key: "amount",
        width: 120,
        validate: true,
        required:true,
        patternMessage:"大于0",
        renderType: "inputnumber",
        width:90,
        render:(text)=>{
            return text && toThousands(text,2);
        },
        filedProps: {
            precision:2,
            except:0,
            min: 0,
        }
    },
    {
        dataIndex: "customerZeroPrice",
        key: "customerZeroPrice",
        title: "客户零供单价",
        renderType: "inputnumber",
        width:90,
        render:(text)=>{
            return text && toThousands(text,2);
        },
        filedProps: {
            precision:2,
            min: 0,
        },
        edit: true,
        required: false,
    },
    {
        dataIndex: "unitPrice",
        key: "unitPrice",
        title: "成交单价",
        renderType: "inputnumber",
        edit: true,
        width:100,
        validate:false,
        patternMessage:"大于等于0的数",
        render:(text)=>{
            return text && toThousands(text,2);
        },
        filedProps: {
            precision:2,
            min: 0,
        },
        required: true,
    },
    {
        dataIndex: "unitMoney",
        key: "unitMoney",
        title: "成交金额",
        // renderType: "inputnumber",
        width:90,
        edit: true,
        render:(text)=>{
            return text && toThousands(text,2);
        },
        filedProps: {
            precision:2,
            min: 0,
        },
        required: false,
    },
    {
        dataIndex: "companyUnitCost",
        key: "companyUnitCost",
        title: "公司单台费用",
        renderType: "inputnumber",
        defaultValue:0,
        render:(text)=>{
            return text && toThousands(text,2);
        },
        filedProps: {
            precision:2,
            min: 0,
        },
        edit: true,
        required: false,
    },  {
        dataIndex: "marketUnitCost",
        key: "marketUnitCost",
        title: "商场单台费用",
        renderType: "inputnumber",
        defaultValue:0,
        width:90,
        render:(text)=>{
            return text && toThousands(text,2);
        },
        edit: false,
        filedProps: {
            precision:2,
            min: 0,
        },
        required: false,
    },
    {
        dataIndex: "basicCommission",
        key: "basicCommission",
        title: "基本提成",
        // renderType: "inputnumber",
        width:100,
        render:(text)=>{
            return text && toThousands(text,2);
        },
        hidepage:{0:true},
        filedProps: {
            precision:2,
        },
        edit: true,
        required: false,
    },
    {
        dataIndex: "changeCommission",
        key: "changeCommission",
        title: "变动提成",
        hidepage:{0:true},
        width:100,
        // renderType: "inputnumber",
        render:(text)=>{
            return text && toThousands(text,2);
        },
        filedProps: {
            precision:2,
        },
        edit: true,
        required: false,
    },
    {
        dataIndex: "withSingleCommission",
        key: "withSingleCommission",
        title: "带单提成",
        hidepage:{0:true},
        width:100,
        // renderType: "inputnumber",
        render:(text)=>{
            return text && toThousands(text,2);
        },
        filedProps: {
            precision:2,
        },
        edit: true,
        required: false,
    },
    {
        dataIndex: "sonProposalUnitPrice",
        key:"sonProposalUnitPrice",
        title: "建议成交价(子公司)",
        // renderType: "inputnumber",
        width:100,
        render:(text)=>{
            return text && toThousands(text,2);
        },
        edit: false,
        filedProps: {
            precision:2,
            min: 0,
        },
        required: false,
    },
    {
        dataIndex: "sonProposalRetailPrice",
        key:"sonProposalRetailPrice",
        title: "建议零售价(子公司)",
        // renderType: "inputnumber",
        width:100,
        render:(text)=>{
            return text && toThousands(text,2);
        },
        edit: false,
        filedProps: {
            precision:2,
            min: 0,
        },
        required: false,
    },
    {
        dataIndex: "invoiceCode",
        key:"invoiceCode",
        title: "发票号",
        renderType: "input",
        pattern:/^\S*$/,
        patternMessage: "不能有空格",
        edit: false,
        filedProps: {
            maxLenght:"20",
        },
        required: false,
    }
]

const columnretailOrderAttachments = [
    {
        title: "标题",
        dataIndex: "filename",
        key: "filename",
        detailwidth: 250,
    }, {
        title: "上传时间",
        dataIndex: "creationTime",
        key: "creationTime",
        detailwidth: 150,
        render: (text, record, index) => {
            return text && ts2Formatter(text,1);
        }
    }, {
        title: "缩略图",
        dataIndex: "fileUrl",
        key: "fileUrl",
        width: 150,
        render: (text, record, index) => {
            if(record.fileUrl.search("jpg") != -1 || record.fileUrl.search("jpeg") != -1 ||record.fileUrl.search("png") != -1){
                return <span>
                <img style={{"width":"35px"}} src={text} />
             </span>
            }else {
                return ""
            }
            
        }
    }, 
    {
        title: "创建人",
        dataIndex: "creator",
        key: "creator",
        width: 150,
    },
    {
        title: "发票号",
        dataIndex: "ext01",
        key: "ext01",
        width: 150,
    }, 
    {
        title: "发票金额",
        dataIndex: "ext03",
        key: "ext03",
        width: 150,
    }, 
    {
        title: "验证结果",
        dataIndex: "ext02",
        key: "ext02",
        width: 150,
    },
    {
        title: "验票说明",
        dataIndex: "ext04",
        key: "ext04",
        width: 150,
    }, 
]
//表单字段

export const FormField = {
    "DataHeader": {
        "title": "基础信息",
        "Field": FormDataHeader
    },
}

//表格弹框表单字段
export const FormTableField = {
}

//渲染成字表表格的头
export const childTableColumn = {
    "retailOrderItems": {
        "title": "明细",
        "type": "grid",
        "column": columnretailOrderItems
    },
    "retailOrderAttachments": {
        "title": "附件",
        "type": "grid",
        "column": columnretailOrderAttachments
    },
}

//渲染成字表表格的头
export const mainTableColumn = [
    {
        title: "零售单号",
        dataIndex: "retailBillCode",
        key: "retailBillCode",
        width:140,
        render: (text, record) => {
            return <a style={{ "cursor": "pointer" }}
                onClick={() => {
                    actions.routing.push(
                        {
                            pathname: 'RetailOrders-edit',
                            search: `?search_id=${record.id}&btnPageFlag=2`,
                        }
                    );
                    // location.reload();
                }}
            >
                {text}
            </a >;
        }
    },
    {
        title: "审批状态",
        dataIndex: "state",
        key: "state",
        width:100,
        render:(text, record, index)=> {
            return renderState(text);
        }
    },
    {
        title: "购机日期",
        dataIndex: "purMachineTime",
        width: 100,
        key: "purMachineTime",
        render(text, record, index) {
            return (text ? ts2Formatter(text) : text)
        },
    },
    {
        title: "零售片区",
        dataIndex: "salesDeptName",
        width: 120,
        key: "salesDeptName",
    },
    {
        title: "销售类型",
        dataIndex: "saleTypeName",
        width: 120,
        key: "saleTypeName",
    },
    {
        title: "套购类型",
        dataIndex: "ext09Name",
        width: 80,
        key: "ext09Name",
    },
    {
        title: "是否赠送支架",
        dataIndex: "ext16",
        width: 120,
        key: "ext16",
        render:(text, record, index)=> {
            if (text==="1") {
                return "是";
            }else if(text==="0"){
                return "否";
            }
        }
    },
    {
        title: "是否售后上门安装",
        dataIndex: "ext17",
        width: 120,
        key: "ext17",
        render:(text, record, index)=> {
            if (text==="1") {
                return "是";
            }else if(text==="0"){
                return "否";
            }
        }
    },
    {
        title: "数量",
        dataIndex: "totalQuantity",
        width: 100,
        key: "totalQuantity",
    },
    {
        title: "门店名称",
        dataIndex: "ownerShopName",
        width: 100,
        key: "ownerShopName",
    },
    {
        title: "门店类别",
        dataIndex: "terminalTypeName",
        width: 120,
        key: "terminalTypeName",
    },
    {
        title: "顾客名称",
        dataIndex: "shopperName",
        width: 120,
        key: "shopperName",
    },
    {
        title: "顾客电话",
        dataIndex: "shopperPhone",
        width: 120,
        key: "shopperPhone",
    },
    {
        title: "顾客电话1",
        dataIndex: "ext01",
        width: 120,
        key: "ext01",
    },
    {
        title: "客户",
        dataIndex: "ownerCustomerName",
        width: 100,
        key: "ownerCustomerName",
    },
    {
        title: "客户渠道",
        dataIndex: "channelName",
        width: 120,
        key: "channelName",
    },
    {
        title: "安装码",
        dataIndex: "installationCode;",
        width: 120,
        key: "installationCode;",
    },
    {
        title: "公司费用汇总",
        dataIndex: "companyUnitCosts",
        width: 100,
        key: "companyUnitCosts",
    },
    {
        title: "商场费用汇总",
        dataIndex: "marketUnitCosts",
        width: 100,
        key: "marketUnitCosts",
    },
    {
        title: "成交额汇总",
        dataIndex: "totalAmount",
        width: 100,
        key: "totalAmount",
    },
    {
        title: "销售订单号",
        dataIndex: "ext03",
        width: 120,
        key: "ext03",
    },
    {
        title: "备注",
        dataIndex: "remark",
        width: 120,
        key: "remark",
    },
    {
        title: "创建人",
        dataIndex: "ext07",
        width: 120,
        key: "ext07",
    },
    {
        title: "修改人",
        dataIndex: "ext08",
        width: 120,
        key: "ext08",
    },
    {
        title: "是否存在附件",
        dataIndex: "ext06",
        width: 120,
        key: "ext06",
        render:(text, record, index)=> {
            if (text==="Y") {
                return "是";
            }else if(text==="N"){
                return "否";
            }
        }
    }
]

export const searchField = [
    {
        enname: "saleOrg",
        zhname: "隶属组织",
        multiple:false,
        realRef:true,
        param:{
            "AUTH_refdim":"saleOrg","AUTH_refcod":"retail_order"
        },
        cascadeName: [{
                paramkey: "EQ_customerAreas.organization.id",
                childtype: "DataHeader",
                refKey: "refpk",
                dtoKey: "saleOrg",
                offers: "ownerCustomer",
                resetOffersFlag: true,
            },
            {
                paramkey: "EQ_customerAreas.organization.id",
                childtype: "DataHeader",
                refKey: "refpk",
                dtoKey: "saleOrg",
                offers: "ext20",
                resetOffersFlag: true,
            },
        ],
        type: "RefComponent",
        refname:"organization",
        edit:true,
    },
    {
        enname:"ownerShop",
        codename:"ownerShopCode",
        showname:"ownerShopName",
        zhname:"门店",
        realRef:true,
        required: false,
        refname:"terminalIsEnable",
        type: "RefComponent",
        edit: true
    },
    {
        enname:"ownerCustomer",
        zhname:"客户",
        required: false,
        realRef:true,
        alias:"saleOrg",
        param:{
            "AUTH_refdim":"ownerCustomer","AUTH_refcod":"retail_order","EQ_isFrozen": "0"
        },
        refname:"terminalcustomerRef",
        type: "RefComponent",
        edit: true
    },
    {
        enname:"state",
        zhname:"审批状态",
        required: false,
        code:"BILL_STATUS",
        type: "Select",
        edit: true
    },
    {
        enname: "purMachineTime",
        zhname: "购机日期段",
        required: false,
        type: "RangePicker",
        rangeField: ["purMachineTime", "purMachineTime"],
        edit: true
    },
    {
        enname: "creationTime",
        zhname: "创建日期段",
        required: false,
        type: "RangePicker",
        rangeField: ["creationTime", "creationTime"],
        edit: true
    },
    {
        enname: "retailBillCode",
        zhname: "零售单号",
        searchType: 'like',
        type: "FormControl",
        edit: true
    },
    {
        enname:"creatorId",
        zhname:"创建人",
        required: false,
        refname:"personRef",
        realRef:true,
        type: "RefComponent",
        edit: true
    },
    {
        enname:"shopperName",
        zhname:"顾客姓名",
        required: false,
        searchType: 'like',
        type: "FormControl",
        edit: true
    },
    {
        enname:"shopperPhone",
        zhname:"联系方式",
        required: false,
        searchType: 'like',
        type: "FormControl",
        edit: true
    },
    {
        enname:"ext20",
        zhname:"归属客户",
        required: false,
        realRef:true,
        alias:"saleOrg",
        param:{
            "AUTH_refdim":"ownerCustomer","AUTH_refcod":"retail_order","EQ_isFrozen": "0"
        },
        refname:"terminalcustomerRef",
        type: "RefComponent",
        edit: true
    },
    {
        enname:"retailOrderItems&brand",
        zhname:"商品品牌",
        required: false,
        refname: 'brandref',
        realRef:true,
        type: "RefComponent",
        edit: true
    },
    {
        enname:"retailOrderItems&productLine",
        zhname:"商品品类",
        required: false,    
        realRef:true,
        refname: "terminalGoodsCate",
        type: "RefComponent",
        edit: true
    },
    {
        enname:"retailOrderItems&ext02",
        zhname:"商品系列",
        required: false,
        realRef:true,
        multiple: true,
        refname: 'goodSeriesRef',
        type: "RefComponent",
        edit: true
    },
    {
        enname:"retailOrderItems&ext03",
        zhname:"商品子系列",
        required: false,    
        realRef:true,
        multiple: true,
        refname: "goodSonSeriesRef",
        type: "RefComponent",
        edit: true
    },
    {
        enname:"retailOrderItems&goods",
        zhname:"商品型号",
        required: false,
        multiple: true,
        realRef:true,
        refname:"goodsRef",
        type: "RefComponent",
        edit: true
    },
    {
        enname:"retailOrderItems&ext11",
        zhname:"条码产权",
        required: false,
        type: "Select",
        options: [
            {
                name: '公司产权', code: "1"
            },
            {
                name: '商家产权', code: "2"
            },
        ],
        edit: true
    },
    {
        enname:"salesDept",
        zhname:"零售片区",
        required: false,
        realRef:true,
        refname:"departmentRef",
        type: "RefComponent",
        edit: true
    },
    {
        enname:"ext11",
        zhname:"零售地区",
        required: false,
        realRef:true,
        refname:"departmentRef",
        type: "RefComponent",
        edit: true
    },
    {
        enname:"ext12",
        zhname:"零售大区",
        required: false,
        realRef:true,
        refname:"departmentRef",
        type: "RefComponent",
        edit: true
    },
    {
        enname:"shippingarea",
        zhname:"发运片区",
        required: false,
        realRef:true,
        refname:"departmentRef",
        type: "RefComponent",
        edit: true
    },
    {
        enname:"ext13",
        zhname:"发运地区",
        required: false,
        realRef:true,
        refname:"departmentRef",
        type: "RefComponent",
        edit: true
    },
    {
        enname:"ext14",
        zhname:"发运大区",
        required: false,
        realRef:true,
        refname:"departmentRef",
        type: "RefComponent",
        edit: true
    },
    {
        enname:"saleType",
        zhname:"销售类型",
        code:"QY132",
        type: "Select",
        edit: true
    },
    {
        enname:"retailType",
        zhname:"零售类型",
        required: false,
        code:"ls001",
        type: "Select",
        edit: true
    },
    {
        enname:"serviceModeSrc",
        zhname:"提货方式",
        required: false,
        code:"ls002",
        type: "Select",
        edit: true
    },
    {
        enname:"channel",
        zhname:"客户渠道",
        required: false,
        realRef:true,
        param:{
            "EQ_enableState":"2"
        },
        refname:"custchantype",
        type: "RefComponent",
        edit: true
    },
    {
        enname:"terminalType",
        zhname:"门店类别",
        refname:"facadeCategoryRef",
        type: "RefComponent",
        realRef:true,
        edit: true
    },
    {
        enname:"ext03",
        zhname:"销售订单号",
        required: false,
        searchType: 'like',
        type: "FormControl",
        edit: true
    },
    {
        enname:"srcBillCode",
        zhname:"来源订单号",
        required: false,
        searchType: 'like',
        type: "FormControl",
        edit: true
    },
    {
        enname:"retailOrderItems&machineBarCode",
        zhname:"条码",
        required: false,
        searchType: 'like',
        code:"ls001",
        type: "FormControl",
        edit: true
    },
    {
        enname:"installationCode",
        zhname:"安装码",
        required: false,
        searchType: 'like',
        type: "FormControl",
        edit: true
    },
    {
        enname:"srcBillOrder",
        // zhname:"相关单号",
        zhname:"数据来源",
        required: false,
        type: "Select",
        options: [
            {
                name: 'APP', code: "APP"
            },
            {
                name: 'PC', code: "PC"
            },
            {
                name: '导入', code: "导入"
            },
        ],
        edit: true
    },
    {
        enname:"ext05",
        zhname:"是否上传发票",
        required: false,
        type: "Select",
        options: [
            {
                name: '是', code: "Y"
            },
            {
                name: '否', code: "N"
            },
        ],
        edit: true
    },
    {
        enname:"ext16",
        zhname:"是否赠送支架",
        required: false,
        type: "Select",
        options: [
            {
                name: '是', code: "1"
            },
            {
                name: '否', code: "0"
            },
        ],
        edit: true
    },
    {
        enname:"ext17",
        zhname:"是否售后上门安装",
        required: false,
        type: "Select",
        options: [
            {
                name: '是', code: "1"
            },
            {
                name: '否', code: "0"
            },
        ],
        edit: true
    },
    // {
    //     enname:"retailOrderItems&invoiceCode",
    //     zhname:"发票号码",
    //     required: false,
    //     searchType: 'like',
    //     type: "FormControl",
    //     edit: true
    // },
    {
        enname: "isIncludedCommission",
        zhname: "是否基本提成计入",
        type: "Radio",
        defaultValue: 1,
        options: [{
            "key": 0,
            "value": "否"
        }, {
            "key": 1,
            "value": "是"
        }],
        edit: true,
    },
    {
        enname: "isChangeCommission",
        zhname: "是否变动提成计入",
        type: "Radio",
        defaultValue: 1,
        options: [{
            "key": 0,
            "value": "否"
        }, {
            "key": 1,
            "value": "是"
        }],
        edit: true,
    },
    {
        enname: "isWithSingleCommission",
        zhname: "带单提成计入",
        type: "Radio",
        defaultValue: 1,
        options: [{
            "key": 0,
            "value": "否"
        }, {
            "key": 1,
            "value": "是"
        }],
        edit: true,
    },{
        enname:"ext06",
        zhname:"是否存在附件",
        required: false,
        type: "Select",
        options: [
            {
                name: '是', code: "Y"
            },
            {
                name: '否', code: "N"
            }
        ],
        edit: true
    },
    {
        enname:"retailOrderAttachments&ext01",
        zhname:"验证发票号",
        required: false,
        searchType: 'like',
        type: "FormControl",
        edit: true
    },
    {
        enname:"retailOrderAttachments&ext02",
        zhname:"发票验证结果",
        required: false,
        type: "Select",
        options: [
            {
                name: '验证通过', code: "验证通过"
            },
            {
                name: '验真不通过', code: "验真不通过"
            },
        ],
        edit: true
    },
    {
        enname:"ext09",
        zhname:"套购类型",
        required: false,
        code:"SUIT_STATUS",
        type: "Select",
        edit: true
    },
    {
        enname:"remark",
        zhname:"备注",
        required: false,
        searchType: 'like',
        type: "FormControl",
        edit: true
    },
]

export const headerButtonSets = [
    {
        event: "ButtonAdd",
        zhname: "新增",
        color: 'primary',
        authcode: "retail_orderadd",
    },
    {
        event: "ButtonCopy",
        zhname: "退货",
        authcode: "retail_orderaddbill",
        method: "post",
    },
]

export const columnButtonSets = {
    "delete": {
        event: "ButtonDel",
        zhname: "删除",
        batch: true,
        method: "post",
        ContentType: 'application/x-www-form-urlencoded;charset=utf-8',
        url: 'occ-b2b-order/b2b/retail-order/delete-order'
    },
    "edit": true,
    "detail": true
}

// export default {mainTableColumn,searchField,headerButtonSets,
//     columnButtonSets,childTableColumn,FormTableField,FormField}
export const SelectCode = ["QY132","ls002","ls001","sale","BILL_STATUS","HSFS","SP","SUIT_STATUS","RESPONSIBLE_GIFTS"]
